package com.slfx.easy.poi.demo;

import cn.afterturn.easypoi.excel.ExcelImportUtil;
import cn.afterturn.easypoi.excel.entity.ImportParams;
import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult;
import org.junit.Test;

import java.io.File;
import java.util.Map;

/**
 * <p>根据模板导出</p>
 *
 * @author slfx
 */
public class ExcelImportByTemplate {

    @Test
    public void importByTemplate() throws Exception{
        ImportParams params = new ImportParams();
        params.setKeyMark("：");
        params.setReadSingleCell(true);
        params.setTitleRows(8);
        params.setLastOfInvalidRow(4);

        ExcelImportResult<Map> result = ExcelImportUtil.importExcelMore(new File("D:/poi/easypoi/收料单.xlsx"),
                Map.class, params);
        for (int i = 0; i < result.getList().size(); i++) {
            System.out.println(result.getList().get(i));
        }
        System.out.println("map =>" + result.getMap().toString());
        System.out.println("项目名称 =>" + result.getMap().get("项目名称："));
    }
}
